#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main() {
    int n = 0, m = 0;
    scanf("%d %d", &n, &m);
    char s[100];
    scanf("%s", s);
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= 4; j++)
        {
            int l = 0, r = 0;
            char c1, c2;
            scanf("%d %d %c %c", &l, &r, &c1, &c2);
            for (int k = l - 1; k <= r - 1; k++)
            {
                if (c1 == s[k])
                    s[k] = c2;
            }
        }
    }
    printf("%s", s);

    return 0;
}